import 'package:flutter/cupertino.dart';
import 'package:flutter_yn_goods/base/controller/base_list_more_controller.dart';
import 'package:flutter_yn_goods/pages/goods_info/comment_list/model/model_comment_list.dart';
import 'package:flutter_yn_goods/utils/http/api.dart';
import 'package:flutter_yn_goods/utils/http/http_manager.dart';
import 'package:get/get.dart';

class CommentListLogic extends BaseListMoreController {
  final int productId = Get.arguments ?? 0;

  // 筛选相关
  // final RxInt currentFilter = 0.obs; // 0: 全部, 1: 好评, 2: 中评, 3: 差评, 4: 有图
  // final RxInt totalComments = 0.obs;
  // final RxInt goodComments = 0.obs;
  // final RxInt normalComments = 0.obs;
  // final RxInt badComments = 0.obs;
  // final RxInt withPicComments = 0.obs;
  final RxInt positiveRate = 0.obs;

  @override
  void onInit() {
    super.onInit();
    initialRefresh = true;
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  // // 切换筛选条件
  // void changeFilter(int filter) {
  //   if (currentFilter.value != filter) {
  //     currentFilter.value = filter;
  //     refreshList();
  //   }
  // }

  @override
  Future<List> loadData() async {
    final params = {
      // 'id': productId,
      'page': pageNum,
      'limit': pageSize,
    };

    final response = await HttpManager().get(
      API.productCommentList + productId.toString(),
      params: params,
      fromJson: ModelCommentList.fromJson,
    );
    return response.data ?? [];
  }
}
